import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author 徒有琴
 */
public class RedisServer {
    public static void main(String[] args) {
        ServerSocket serverSocket = null;
        InputStream input = null;// 用于读取别人发过来的消息
        try {
            serverSocket = new ServerSocket(8888);
            Socket socket = serverSocket.accept();
            input = socket.getInputStream();
            byte[] arr = new byte[1024];
            int len;
            while ((len = input.read(arr)) != -1) {
                String message = new String(arr, 0, len);
                System.out.print(message);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                input.close();
                serverSocket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
